fn main() {
    println!("Hello, world!");

    //struct

    //结构体实例化
let mut user = User{
    email:String::from("1134334@qq.com"),
    username:String::from("zxx"),
    sign_in_count:43,
    active:true,
};

//结构体赋值,前提结构体的实例是mut,并且如果结构体的实例是可变的,那么结构体中的每个字段都是mut
user.email = String::from("1121211@gmail.com");



//结构体的更新
let  user1 = User{
    email:String::from("11343rr34@qq.com"),
    username:String::from("112"),
    sign_in_count:user.sign_in_count,
    active:user.active,
};

// 如果实例2的某些是实例1的一部分,上面的可以改写成
let  user1 = User{
    email:String::from("11343rr34@qq.com"),
    username:String::from("112"),
    ..user
};
}


//结构体作为函数的返回值
fn build_user(email:String,username:String)->User{
    User{
        email:email,
        username:username,
        sign_in_count:43,
        active:true,
    }
}

struct User{
    email:String,
    username:String,
    sign_in_count:u64,
    active:bool,
}
